package com.controller;

import com.service.IIssueCommentService;
import com.service.IUserLikeWithIssueService;
import com.service.IUserLikeWithSonCommentService;
import com.websocketOfNotice.msgAnno.Notice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import living.com.result.ApiResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author 大忽悠
 * @create 2022/2/9 19:42
 */
@Api(tags = "点赞请求处理")
@RestController
@RequiredArgsConstructor
public class LikeController {
    private final IUserLikeWithIssueService iUserLikeWithIssueService;
    private final IIssueCommentService iIssueCommentService;
    private final IUserLikeWithSonCommentService iUserLikeWithSonCommentService;
    @Notice(id_index = 0,notice_type = "LIKE_ON_ISSUE")
    @ApiOperation("点赞指定id对应的问题")
    @PostMapping("/likeIssue")
    public ApiResult<Boolean> likeTargetIssue(@ApiParam("问题id")@RequestParam Integer issue_id)
    {
        return ApiResult.success(iUserLikeWithIssueService.likeTargetIssue(issue_id));
    }


    @ApiOperation("取消点赞指定id对应的问题")
    @DeleteMapping("/likeIssue")
    public ApiResult<Boolean> unLikeTargetIssue(@ApiParam("问题id")@RequestParam Integer issue_id)
    {
        return ApiResult.success(iUserLikeWithIssueService.unLikeTargetIssue(issue_id));
    }


   @Notice(id_index = 0,notice_type = "LIKE_ON_COMMENT")
    @ApiOperation("赞同指定评论")
    @PostMapping("/likeComment")
    public ApiResult<Boolean> likeTargetComment(@ApiParam("评论id")@RequestParam Integer comment_id)
    {
        boolean res=iIssueCommentService.likeTargetComment(comment_id);
        return ApiResult.success(res);
    }

    @ApiOperation("取消赞同指定评论")
    @DeleteMapping("/likeComment")
    public ApiResult<Boolean> unLikeTargetComment(@ApiParam("评论id")@RequestParam Integer comment_id)
    {
        boolean res=iIssueCommentService.unLikeTargetComment(comment_id);
        return ApiResult.success(res);
    }


    @Notice(id_index = 0,notice_type = "LIKE_ON_SON_COMMENT")
    @ApiOperation("赞同指定儿子评论")
    @PostMapping("/likeSonComment")
    public ApiResult<Boolean> likeTargetSonComment(@ApiParam("儿子评论id")@RequestParam Integer son_comment_id)
    {
        boolean res=iUserLikeWithSonCommentService.likeTargetSonComment(son_comment_id);
        return ApiResult.success(res);
    }


    @ApiOperation("取消赞同指定儿子评论")
    @DeleteMapping("/unLikeSonComment")
    public ApiResult<Boolean> unLikeTargetSonComment(@ApiParam("儿子评论id")@RequestParam Integer son_comment_id)
    {
        boolean res=iUserLikeWithSonCommentService.unLikeTargetSonComment(son_comment_id);
        return ApiResult.success(res);
    }
}
